package com.shilei.cor;

import com.shilei.*;

/**
 * @description: 子弹墙碰撞
 * @author: 81271
 * @date: 2020-04-15 20:17
 */
public class BulletWallCollider implements Collider {

    @Override
    public boolean collide(GameObject go1, GameObject go2) {
        if (go1 instanceof Bullet && go2 instanceof Wall) {
            Bullet bullet = (Bullet)go1;
            Wall wall = (Wall)go2;

            if (bullet.getRect().intersects(wall.getRect())) {
                bullet.die();
            }
            return true;
        } else if (go1 instanceof Wall && go2 instanceof Bullet) {
            collide(go2, go1);
        }
        return false;



    }

}
